package com.example.springbootjdbc.controller;

import com.example.springbootjdbc.pojo.Users;
import com.example.springbootjdbc.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.sql.DataSource;
import java.io.File;

/**
 * @ClassName UsersController
 * @Description UsersController
 * @Author ZX
 * @Date 2020/5/26
 */
@RestController
public class UsersController {
    @Autowired
    private UsersService usersService;


    @Autowired
    private DataSource dataSource;

    @GetMapping("/showInfo")
    public String showInfo(){
        System.out.println(dataSource.getClass().getPackage());
        return "OK";
    }

    /**
     * @Description: 用户添加
     * @Param:
     * @return:
     */
    @RequestMapping("/addUserController")
    public String addUser(Users users){
        try{
            this.usersService.addUser(users);
        }catch (Exception e){
            e.printStackTrace();
            return "error";
        }
        return "OK";
    }

}
